package cc.spider.processor;

import cc.spider.core.IDataProcessor;
import cc.spider.model.FlowData;
import cc.spider.model.ResultInfo;
import cc.spider.model.TaskInfo;

import java.util.HashMap;
import java.util.Map;

public class SimpleDataProcessor implements IDataProcessor {
    @Override
    public void process(FlowData flowData) {
        ResultInfo<String> response = flowData.getResultInfo();
        Map<String, Object> map = new HashMap<>();
        map.put("emptyDataProcessor", response.getResult());
        int rn = (int) (Math.random() * 10);
        if (rn < 6) {
          //  rn = 0;
        }

        while (rn-- > 0){
            flowData.addNextTaskInfo(new TaskInfo() {
                @Override
                public int getPriority() {
                    return 0;
                }

                @Override
                public void setPriority(int priority) {

                }
            });
        }

        flowData.setFields(map);
    }
}
